package net.awpspace.mobile.management.point;

import java.util.Vector;
import javax.microedition.midlet.MIDlet;
import com.sun.lwuit.List;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import net.awpspace.mobile.form.BaseForm;
import net.awpspace.mobile.global.Utils;

public class TinhDiem extends BaseForm {

	private List list;
	private Vector data;	
	public TinhDiem(MIDlet app, BaseForm parent) {
		super(app, parent);
		setTitle("Member View");
		setTransitionInAnimator(CommonTransitions.createSlide(
				CommonTransitions.SLIDE_HORIZONTAL, true, 1200));
		setTransitionOutAnimator(CommonTransitions.createSlide(
				CommonTransitions.SLIDE_HORIZONTAL, true, 1200));
		
		list = new List();
		list.setSmoothScrolling(true);
		list.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent arg0) {
				itemStateChanged();
			}
		});
		data = Data.getInstance().getData();
		createComponent();
		
	}
	
	protected void itemStateChanged() {	
		int index = list.getSelectedIndex();
		Diem d = (Diem)data.elementAt(index);
		Utils.getInstance().alert("Điểm trung bình của sinh viên " + d.getTen() + " : " + d.getTrungbinh());
	}

	public void createComponent(){
		for(int i = 0; i < data.size(); i++){
			list.addItem(((Diem)data.elementAt(i)).getTen());
		}
		addComponent(list);
	}
		
	protected void processCommand(ActionEvent e) {

	}
}